package com.chinaisafe.user.dto;

import com.chinaisafe.user.entity.SysTenant;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.io.Serializable;

/**
 * SysTenantDTO
 * Description：租户数据传输对象
 *
 * @author xuefu.shu
 * @date  2024-07-12 10:22:08
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysTenantDTO", description = "租户数据传输对象")
public class SysTenantDTO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    private Long id;

    @Schema(description = "名称")
    private String name;

    @Schema(description = "租户编码")
    private String code;

    @Schema(description = "简称")
    private String alias;

    @Schema(description = "统一信用代码")
    private String creditCode;

    @Schema(description = "上级租户")
    private Long parentId;

    @Schema(description = "租户类型")
    private String type;

    @Schema(description = "系统运行日")
    private LocalDate useStartDate;

    @Schema(description = "租期")
    private LocalDate tenancyDate;

    @Schema(description = "是否启用")
    private Boolean enable;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "管理员id")
    private Long managerUserId;


    /**
     * 将实体类转换为数据传输对象
     * @param entity 实体对象
     * @return SysTenantDTO 数据传输对象
     * @author xuefu.shu
     * @date 2024-07-12 10:22:08
     */
    public static SysTenantDTO convertFromEntity(SysTenant entity) {
        SysTenantDTO dto = new SysTenantDTO();
        dto.id = entity.getId();
        // 给对应的字段赋值 可根据实际业务删减
        dto.name = entity.getName();
        dto.code = entity.getCode();
        dto.alias = entity.getAlias();
        dto.creditCode = entity.getCreditCode();
        dto.parentId = entity.getParentId();
        dto.type = entity.getType();
        dto.useStartDate = entity.getUseStartDate();
        dto.tenancyDate = entity.getTenancyDate();
        dto.enable = entity.getEnable();
        dto.remark = entity.getRemark();
        dto.managerUserId = entity.getManagerUserId();
        return dto;
    }
}
